﻿@{
    ViewBag.Title = "Common Command";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<ol class="breadcrumb">
    <li><a href="/Home.html">Home</a></li>
    <li><a href="/WebApp/WebApi"> Sanelib WebApp</a></li>
    <li class="active">Member</li>
</ol>

            <div id="introduction">
                <h1 class="text-left">API Controller</h1>
                <h4>Member Controller</h4>
            </div>
            <div>
                <h4>Class Inherited<a href="/WebApp/SmartApi" class="btn-link">SmartApiController</a></h4>

                <article>
                    <p>Member Controller is the module which contains the Member related changes like Change Password, Recover Password, Search for a Specification and go to another URL.</p>
                    <pre><code>[Authorize]
        public HttpResponseMessage Get([FromUri] MemberLookupForm form)
        {
         var searchSpecification = new SearchSpecification { FindLike = false };</code></pre>
                    Now, If Member id is retrieved via Search Specification then ID and MemberId from the form object received in the constructor of the MemberController.
                    If the search from Id is not successfull it tries for the TagId and then Code.
                    <pre><code>
var memberviewPage = _memberViewRepository.SearchBySpecification(searchSpecification, Property.Of&lt;memberview>(x => x.DateOfBirth));
var searchSpecificationResponse = Mapper.Map&lt;page &lt;memberview>, PageResponse&lt;memberline>>(memberviewPage);
return Content(searchSpecificationResponse.TotalItems > 0 ? searchSpecificationResponse.Items[0] : null);
</code>This Search is done by Date Of Birth and Mapped via Automapper for diffrent entities of the User.</pre>
                    <h3>Method : Post</h3>
                    Description : Arguments as Form (RegistrationForm)
                    <code>public HttpResponseMessage Post(RegistrationForm form)</code>

                    <p>The form object in the Post Method checks the validation of the Registration Form of  the member and returns content to the <a href="/WebApp/SmartApi" class="btn-link">ApiController</a></p>
                    <code>return Content(validationResult);</code>

                    The function also checks for the file type of the image of the profile, if its not an image type defined by the function it will throw an error of type validation error that file not supported.
                    After image is recognized and location is known, the Event Co-ordinator Raises an new memberRegistration event to recover password.
                    <br />
                    <pre>EditMember Mapping<code>[Authorize]
public HttpResponseMessage Put(EditMemberForm form)
{
var command = MappingEngine.Map&lt;editmemberform, editmember>(form);
return ExecuteCommand(command);
}</code>The Mapping Engine maps the member with its form and execute the command form commands and processor.</pre>
                </article>
                <div id="extra">
                    There are two more Member Controller Implementation<br />
                    <a href="/WebApp/AccountRecovery" class="btn-link">Delete</a>
                    <a href="/WebApp/AccountRecovery" class="btn-link">GetPasswordRecovery</a>
                </div>
                <div>
                    <h3>Member Notifications</h3>
                    <p>Notification are:</p>
                    <ol>
                        <li>SMS</li>
                        <li>Mail</li>
                        <li>UsePrint</li>
                    </ol>
                    <p>
                        An NotificationForm[] array object contains code, black and all bool status of the notifcation in the array of the member object.<br />
                        An UpdateMemberNotification class object is used to change the current setting of the member notification.
                    </p>
                    <pre><code>
var command = new UpdateMemberNotification
{
    Memberes = notificationForms.Select(x => new MemberNotification
    {
         Code = x.Code,
         Block = x.Block,
         SendSms = x.SendSms,
         SendEmail = x.SendEmail,
         UsePrint = x.UsePrint
     }).ToArray()
};
    return ExecuteCommand(command);
</code>Used as an command to update notification.</pre>
                    <a href="#">Watch The Flow of the system</a>


                </div>
            </div>
      